import Vue from 'vue'
import Vuex from 'vuex'
import cloneDeep from 'lodash/cloneDeep'
import common from './modules/common'
import user from './modules/user'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		userId: '',
		relationId: '',
	},
  modules: {
    common,
    user
  },
  mutations: {
    // 重置vuex本地储存状态
    resetStore (state) {
		console.log('state',state,'``',window)
		// if(window.SITE_CONFIG){
			Object.keys(state).forEach((key) => {
			  state[key] = cloneDeep(window.SITE_CONFIG['storeState'][key])
			})
		// }
      
    },
	  updateUserId (state, userId) {
		  state.userId = userId
	  },
	  updateRelationId (state, relationId) {
		  state.relationId = relationId
	  }
  },
  strict: process.env.NODE_ENV !== 'production'
})
